﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Facebook.Service;

namespace FriendsNearby.Services.Facebook
{
    class FacebookNETServiceFactory : IFacebookServiceFactory
    {
        #region IFacebookServiceFactory Members

        public IFacebookService Create(string appKey, string secret, string sessionKey, string userID)
        {
            return new FacebookNETService(new FacebookService(appKey, secret, sessionKey, userID));
        }

        #endregion
    }

    class FacebookNETService : IFacebookService
    {
        FacebookService service;

        public FacebookNETService(FacebookService service)
        {
            this.service = service;
        }

        public string UserID
        {
            get { return service.UserID; }
        }

        public string UserName
        {
            get
            {
                return service.Users.GetUser(UserID, "name").Name;
            }
        }

        public bool IsValid()
        {
            User myUser = service.Users.GetUser(UserID, "name");
            return myUser != null;
        }

        public IEnumerable<string> GetFriends(FriendFilter filter)
        {
            return service.Friends.GetFriends(filter);
        }

        public string SendNotification(string userID, string notification, string email)
        {
            return service.Notifications.SendNotification(userID, notification, email);
        }
    }
}
